export const msg = (title, duration = 1500, mask = false, icon = 'none') => {
  //统一提示方便全局修改
  if (Boolean(title) === false) {
    return
  }
  uni.showToast({
    title,
    duration,
    mask,
    icon,
  })
}
export const showinfo = (userinfo) => {
  if (userinfo.userPname == '') {
    uni.showModal({
      title: '温馨提示',
      content: '我们建议您到个人中心,完善个人信息\r\n便于您下次参与时不必重复录入',
      cancelText: '下次再说',
      confirmText: '去修改',
      success: (res) => {
        if (res.confirm) {
          uni.navigateTo({
            url: `/pages/personalInfor/personalInfor`,
          })
        }
      },
    })
  }
}
//展示这个loading
export const showLoading = ({ title = '', mask = true } = { title: '申请中', mask: true }) => {
  uni.showLoading({
    title: title || '申请中',
    mask: mask || true,
  })
}
//隐藏加载loading
export const hideLoading = (del = 2000) => {
  setTimeout(() => {
    uni.hideLoading()
  }, del)
}
//点击左是角返回上一页
export const leftBack= ()=>{
  uni.navigateBack()
}
//进入不同的路由地址
export const handleMenu = (url) => {
  if (!url) return false
  uni.navigateTo({
    url,
  })
}

//判断信息是否过期了
export const personalModal = (content = '请前往个人中心完善信息') => {
  uni.showModal({
    title: '提示',
    content,
    success: (res) => {
      if (res.confirm) {
        handleMenu('/pages/personalInfor/personalInfor')
      }
    },
  })
}
export const paramsShowmodal=(params)=>{
  const {title,content,success,fail} = params
  uni.showModal({
    title: title|| '提示',
    content: content||'是否需要处理?',
    success,
    fail,
  });
}
//根据轮播数据进行跳转
export const handleMenus = (router, type) => {
  if (type === 'abc') {
    if (router.toString().startsWith('http://') || router.toString().startsWith('https://')) {
      handleMenu(router.split('#')[1])
    }
  }
}

//图片展示
export const getImgUrl = (value) => {
  if (value.indexOf('http') != -1) {
    return value
  } else {
    return process.uniEnv.imageUrl + value
  }
}
//打电话
export const makePhoneCall = (phoneNumber) => {
  if (!phoneNumber.length) {
    msg('联系方式不存在')
    return
  }
  uni.makePhoneCall({
    phoneNumber,
  })
}
